package code.hkgolden.android.core;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import code.hkgolden.android.R;

public class HkgoldenMessagingManager {
	private static int NOTIFICATIONS_ID = 1;
	private NotificationManager mNotificationManager;
	private Activity activity;
	private Class activityClass;

	public HkgoldenMessagingManager(Activity activity) {
		mNotificationManager = (NotificationManager) activity
				.getSystemService(Activity.NOTIFICATION_SERVICE);
	}

	protected void showToast(int type) {
		LayoutInflater vi = (LayoutInflater) activity
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = vi.inflate(R.layout.toast, null);

		TextView tv = (TextView) view.findViewById(R.id.content);
		tv.setText("??");

		Toast toast = new Toast(activity);
		toast.setView(view);
		toast.setDuration(type);
		toast.show();
	}

	private void setWeather(String tickerText, String title, String content,
			int drawable) {

		Notification notification = new Notification(drawable, tickerText,
				System.currentTimeMillis());

		PendingIntent contentIntent = PendingIntent.getActivity(activity, 0,
				new Intent(activity, activityClass), 0);

		notification
				.setLatestEventInfo(activity, title, content, contentIntent);
		notification.vibrate = new long[] { 100, 250, 100, 500 };

		mNotificationManager.notify(NOTIFICATIONS_ID, notification);
	}

	private void setDefault(int defaults) {

		PendingIntent contentIntent = PendingIntent.getActivity(activity, 0,
				new Intent(activity, activityClass), 0);

		String title = "����Ԥ��";
		String content = "�������";

		final Notification notification = new Notification(0, content, System
				.currentTimeMillis());

		notification
				.setLatestEventInfo(activity, title, content, contentIntent);
		notification.vibrate = new long[] { 100, 250, 100, 500 };

		notification.defaults = defaults;

		mNotificationManager.notify(NOTIFICATIONS_ID, notification);
	}

}
